/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.pasatelsys.gw.charging;

import com.pasatelsys.gw.domain.helper.SubType;
import com.pasatelsys.gw.util.GWUtils;
import java.math.BigDecimal;
import javax.jws.WebService;
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.ejb.Stateless;

/**
 *
 * @author User
 */
@WebService(serviceName = "ChargingWS")
@Stateless()
public class ChargingWS {

    /**
     * Web service operation
     */
    @WebMethod(operationName = "processCharging")
    public ResponseCharging processCharging(@WebParam(name = "msisdn") String msisdn, @WebParam(name = "amount") BigDecimal amount, @WebParam(name = "username") String username, @WebParam(name = "password") String password, @WebParam(name = "chargeType") String chargeType, @WebParam(name = "contents") String contents, @WebParam(name = "requestId") Integer requestId) {
        ResponseCharging response = new ResponseCharging();


        try {
            //Validate msisdn
            for (int i = 0; i < msisdn.length(); i++) {
                String str = msisdn.substring(i, i + 1);
                try {
                    Integer.parseInt(str);
                } catch (NumberFormatException e) {
                    return GWUtils.setResponseCharging(response, 1, "Invalid MSISDN", requestId, SubType.PREPAID);
                }
            }
            //Validating Username/Password
            
            
        } catch (Exception e) {
            return GWUtils.setResponseCharging(response, 23, "Unexpected error", requestId, SubType.PREPAID);
        }

        //TODO write your implementation code here:
        return response;
    }
}
